"""
日志配置模块 - 兼容性实现
"""

def get_logging_config(service_name: str = "default"):
    """获取日志配置"""
    return {
        'version': 1,
        'disable_existing_loggers': False,
        'formatters': {
            'default': {
                'format': f'[%(asctime)s] {service_name} - %(levelname)s: %(message)s',
            }
        },
        'handlers': {
            'console': {
                'class': 'logging.StreamHandler',
                'formatter': 'default'
            }
        },
        'loggers': {
            service_name: {
                'level': 'INFO',
                'handlers': ['console'],
                'propagate': False
            }
        }
    }

def setup_logging(service_name: str = "default"):
    """设置日志"""
    import logging.config
    config = get_logging_config(service_name)
    logging.config.dictConfig(config)
    return logging.getLogger(service_name)

def configure_logging(config_dict=None, service_name="default"):
    """配置日志 - 兼容性函数"""
    import logging.config
    if config_dict is None:
        config_dict = get_logging_config(service_name)
    logging.config.dictConfig(config_dict)
    return logging.getLogger(service_name)
